import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'DatailPage.dart';

class RouterPageParamsPage extends StatelessWidget {
  final SystemUiOverlayStyle _style =
      SystemUiOverlayStyle(statusBarColor: Colors.transparent);

  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(_style);
    // TODO: implement build
    return MaterialApp(
      home: RouterPageParamsStatefulWidget(),
      theme: ThemeData(primarySwatch: Colors.yellow),
    );
  }
}

class RouterPageParamsStatefulWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _RouterPageParamsState();
  }
}

class _RouterPageParamsState extends State<StatefulWidget> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(
        title: Text("RouterPageParams Page"),
      ),
      body: ListPage(),
    );
  }
}

class ListPage extends StatelessWidget {
  List _data = [
    {"id": 1, "name": "iphone"},
    {"id": 1, "name": "huawei"},
    {"id": 1, "name": "xiaomi"},
    {"id": 1, "name": "oppo"},
    {"id": 1, "name": "vivo"},
  ];

  @override
  Widget build(BuildContext context) {
    return ListView.builder(itemBuilder: (context,index){
        return ListTile(
          title: Text(_data[index]["name"]),
          onTap: (){
            String result = Navigator.push(context, MaterialPageRoute(builder: (context) => DetailPage(_data[index]["id"],_data[index]["name"]))).toString();
            print("ListView.builder 返回值： " + result);
          },
        );
    },
    itemCount: _data.length,);
  }
}
